import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        showLogin: false,
        wxInfo: "",
        token: "",
        userInfo: "",
        signature: '',  //签名
        ifFirst: true,    //判断是否第一次进入首页，如果不是第一次进入首页就不调接口
        homeData: null,
        system: {}
    },
    mutations: {

        //设置进入首页状态
        SET_IF_FIRST(state, bool){
            state.ifFirst = bool;
        },

        //设置进入首页状态
        SET_HOME_DATA(state, data){
            state.homeData = data;
        },


        //设置微信用户信息
        SET_WX_INFO(state, data){
            state.wxInfo = data;
        },

        //设置token
        SET_TOKEN(state, token){
            state.token = token;
        },

        //设置用户信息
        SET_USERINFO(state, data){
            state.userInfo = data;
        },

        //判断是否已经登录，如果未登录显示登录框
        SET_LOGIN_STATUS(state, status){
            state.showLogin = status;
        },


        SET_SIGNATURE(state, signature){
            state.signature = signature;
        },
        SET_SYSTEM(state, data){
            state.system = data;
        }
    },
    actions: {

    },
    modules: {},
    getters: {
        wxInfo: state => state.wxInfo,
        system: state => state.system,
        userInfo: state => state.userInfo,
        token: state => state.token,
        showLogin: state => state.showLogin,
        signature: state => state.signature,
        ifFirst: state => state.ifFirst,
        homeData: state => state.homeData,
    }
})
